package com.data.modules.online.cgform.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.data.common.util.ConvertUtils;
import com.data.modules.online.cgform.entity.OnlCgformField;
import com.data.modules.online.cgform.entity.OnlCgformHead;
import com.data.modules.online.cgform.mapper.OnlCgformFieldMapper;
import com.data.modules.online.cgform.mapper.OnlCgformHeadMapper;
import com.data.modules.online.cgform.service.IOnlineBaseAPI;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Iterator;
import java.util.List;

@SuppressWarnings("ALL")
@Slf4j
@Service
public class OnlineBaseAPIServiceImpl implements IOnlineBaseAPI {
    @Autowired
    private OnlCgformFieldMapper onlCgformFieldMapper;
    @Autowired
    private OnlCgformHeadMapper onlCgformHeadMapper;

    private static /* synthetic */ java.lang.Object m181a(java.lang.invoke.SerializedLambda r4) {
        /*
        // Method dump skipped, instructions count: 204
        */
        throw new UnsupportedOperationException("Method not decompiled: com.data.modules.online.cgform.service.p013a.OnlineBaseAPIServiceImpl.m181a(java.lang.invoke.SerializedLambda):java.lang.Object");
    }


@Override
public java.lang.String getOnlineErpCode(String code, String tableType) {
        if ("3".equals(tableType)) {
            String var3 = code.substring(1);
            OnlCgformHead var4 = (OnlCgformHead)this.onlCgformHeadMapper.selectById(var3);
            if (var4 != null && var4.getTableType() == 3) {
                LambdaQueryWrapper var5 = new LambdaQueryWrapper();
                var5.eq("cgform_head_id", var3);

                List var6 = this.onlCgformFieldMapper.selectList(var5);
                if (var6 != null && var6.size() > 0) {
                    String var7 = null;
                    Iterator var8 = var6.iterator();

                    while(var8.hasNext()) {
                        OnlCgformField var9 = (OnlCgformField)var8.next();
                        if (ConvertUtils.isNotEmpty(var9.getMainTable())) {
                            var7 = var9.getMainTable();
                            break;
                        }
                    }

                    LambdaQueryWrapper var11 = new LambdaQueryWrapper();
                    var11.eq("table_name", var7);
                    OnlCgformHead var12 = (OnlCgformHead)this.onlCgformHeadMapper.selectOne(var11);
                    String var10 = var12.getThemeTemplate();
                    if (var12 != null && ("innerTable".equals(var10) || "erp".equals(var10))) {
                        code = "/" + var12.getId();
                    }
                }
            }
        }

        return code;
    }
}
